#include "http_service_test.h"
#include <fermat/common/string.h>
#include <cstdlib>


HttpServiceTest::HttpServiceTest(): _server(NULL)
{

}
HttpServiceTest::~HttpServiceTest()
{

}
int HttpServiceTest::run()
{
	std::string thnumstr = _conf->getValue("thread_num","1");
	int thnum = fermat::string_to_int(thnumstr);
	std::string servername = _conf->getValue("service_name","http_test_server");
	std::string addr = _conf->getValue("server_listen_addr","0.0.0.0:8099");
	fermat::net::SocketAddress serveraddr;
	serveraddr.set(addr.c_str());
	_serverBaseloop = _th.start();
	if(!_serverBaseloop) {
		return -1;
	}
	_server = new HttpServerTest(_serverBaseloop, serveraddr, servername, thnum);
	if(!_server) {
		return -1;
	}
	_server->start();
	return 0;
}

void HttpServiceTest::dispose()
{
	if(_server) {
		delete _server;
		_server = NULL;
	}
}


